<template>
	<view>
		<cu-custom bgColor="bg-gradual-pink" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">转工序</block>
		</cu-custom>
		
		<form>
			<view class="cu-form-group">
				<view class="title">工单号输入:</view>
				<input placeholder="请输入工单号" name="input" @input="changWo" v-model="myFormData.workOrderNumber"></input>
			    <button v-if="itemChilds.length>0" class="cu-btn bg-yellow lg" @click="openSubOrder" >子工单</button>
			</view>
			<view class="cu-form-group" style="display: inline;line-height: 3;background: #f5f0f0;">
				<span  v-for="(item, index) in workOrderProcesses " :key="index">
<!-- 				  <span v-if="item.qty && item.qtyWorkOrder && item.qty >= item.qtyWorkOrder " @tap="dispList(item)" class="spanStyle1">{{ item.processId_dictText}}</span>
				  <span v-else-if="!item.qty"  @tap="dispList(item)" class="spanStyle2">{{ item.processId_dictText}}</span>
				  <span v-else  @tap="dispList(item)"  class="spanStyle">{{ item.processId_dictText}}</span> -->
				  <span v-if="(item.qty == null?0:item.qty) >= (item.qtyWorkOrder == null?0:item.qtyWorkOrder)" @tap="dispList(item)" class="spanStyle1">{{ item.processId_dictText}}</span>
				  <span v-else-if="item.processAttribute == 2 && item.qtyOutIssue && item.qtyWorkOrder && item.qtyOutIssue < item.qtyWorkOrder"  @tap="dispList(item)" class="gProgress">{{ item.processId_dictText}}</span>
				  <span v-else-if="item.processAttribute == 2 && item.qtyOutIssue && item.qtyWorkOrder && item.qtyOutIssue >=item.qtyWorkOrder"  @tap="dispList(item)" class="spanStyle">{{ item.processId_dictText}}</span>
				  <span v-else-if=" !item.qty" class="spanStyle2"  @tap="dispList(item)" >{{ item.processId_dictText}}</span>
				  <span v-else  @tap="dispList(item)"  class="spanStyle">{{ item.processId_dictText}}</span>
				</span>
				
			</view>
			<view class="cu-form-group">			
				<view class="title">工艺名称:</view>			
				<view  class="action" style="width: 140px; margin-right: 80px;">
					<uni-data-select :disabled="empProcess" v-model="myFormData.id"  :localdata="range" @change="change"></uni-data-select>
				</view>
		   </view>		   


			<view class="cu-form-group">
				<view class="title" style="width: 200rpx;">客户料号:</view>
				<view class="action" style="width: 222px;">
					<text class="text-grey">{{myFormData.custCode}}</text>
				</view>
			</view>
<!-- 		   <view class="cu-form-group">
			   <view class="title" style="width: 200rpx;">生产人员</view>
			   <view class="action" style="width:222px;">
				<text class="text-grey" >{{myFormData.employee}}</text>
				<button v-if="queryAbnVisual" class="cu-btn bg-gradual-orange lg" @click="queryAbn" style="margin-left: 80px;">异常记录</button>
			   </view>
		   </view> -->
		   <view class="cu-form-group">
		   	<view class="title" style="width: 200rpx;">工单数量:</view>
		   	<view class="action" style="width: 222px;">
		   		<text class="text-grey">{{myFormData.woQty}}</text>
                <button v-if="queryAbnVisual" class="cu-btn bg-gradual-orange lg" @click="queryAbn" style="margin-left: 80px;">异常记录</button>				
		   	</view>
		   </view>
			<view class="cu-form-group">
				<view class="title" style="font-size: 42rpx;">{{compQtyName + ":"}}</view>
				<input type="number" :focus="focusState" :placeholder="'输入' + compQtyName" name="input"  v-model="myFormData.qty"></input>

			</view>
			<view class="cu-form-group container-btn">
					<button class="cu-btn bg-blue lg" :disabled="completeFlag" @click="onSubmit(0)">确定</button>
					<button  class="cu-btn bg-green lg" @click="scan" style="margin-left: 46px;">扫码</button>
					
			</view>
			<view class="cu-form-group" >
<!-- style="border: 1px;"						   -->
			</view>

			<view class="cu-form-group">
				<view class="title" style="width: 200rpx;">产品名称:</view>
				<view class="action" style="width: 222px;">
					<text class="text-grey">{{myFormData.name}}</text>
				</view>
			</view>			
			<view class="cu-form-group">

				<view class="title" style="width: 222rpx;">版本:</view>
				<view class="action" style="width: 222rpx;">
					<text class="text-grey">{{myFormData.productVer}}</text>
				</view>
			</view>
		   <view class="cu-form-group">
			   <view class="title" style="width: 200rpx;">生产人员</view>
			   <view class="action" style="width:222px;">
				<text class="text-grey" >{{myFormData.employee}}</text>				
			   </view>
		   </view>			
<!-- 			<view class="cu-form-group">
				<view class="title" style="width: 200rpx;">工单数量:</view>
				<view class="action" style="width: 222px;">
					<text class="text-grey">{{myFormData.woQty}}</text>
				</view>
			</view> -->
			<view class="cu-form-group">
				<view class="title" style="width: 200rpx;">待转数量:</view>
				<view class="action" style="width: 222px;">
					<text class="text-grey">{{myFormData.balanceQty==null?'':myFormData.balanceQty}}</text>
				</view>
			</view>
			<view class="example-body">
<!-- 				<button type="primary" @click="showDrawer('showLeft')"><text class="word-btn-white">显示Drawer</text>
				</button> -->
<!-- 				<uni-drawer ref="showLeft" mode="left" :width="280" :mask-click="true" @change="changeDraw($event,'showLeft')">
					<view class="scroll-view">
						<scroll-view class="scroll-view-box" scroll-y="true">							
							<view class="uni-flex uni-row" style="-webkit-flex: 1;flex: 1; margin-top: 70px; margin-left: 10px; line-height: 2;" >
								<view style="display: flex;">
									<view class="text" style="width: 200rpx;">工序1</view>
									<view class="text" style="width: 100rpx;">数量</view>
									<view class="text" style="width: 200rpx;">员工</view>
									<view class="text" style="width: 200rpx;">操作</view>
									<view class="text" style="width: 240rpx;">时间1</view>
								</view>
								<view style="display: flex;" v-for="(process,key) in this.recpList" :key="key">
									<view class="text" style="width: 200rpx;">{{process.processName}}</view>
									<view class="text" style="width: 100rpx;"> {{process.qty}}</view>
									<view class="text" style="width: 200rpx;"> {{process.createBy_dictText}}</view>
									<view class="text" style="width: 200rpx;"> {{process.dataFrom}}</view>
									<view class="text" style="width: 240rpx;"> {{process.createTime.substr(0, 10)}}</view>
								</view>
							</view>
						</scroll-view>
					</view>
				</uni-drawer> -->
				<drawer :show="processDrawerShow" @cancel="processCancel" @ensure="processEnsure" >
				<!--            <view>右往左滑动</view>
				            <view>自定义内容</view>		 -->	
							<view style="margin-top: 140rpx;">
							<uni-table ref="table" :loading="loading" border stripe type="selection" emptyText="暂无更多数据" @selection-change="selectionChange">
								<uni-tr>
									<uni-th width="50" align="center">序号</uni-th>		
									<uni-th width="150" align="center">工序</uni-th>
									<uni-th width="150" align="center">数量</uni-th>
									<uni-th width="120" align="center">员工</uni-th>
									<uni-th width="150" align="center">操作</uni-th>
									<uni-th width="120" align="center">时间</uni-th>
								</uni-tr>
								<uni-tr v-for="(item, index) in recpList" :key="index">
									<uni-td>{{ (index + 1) }}</uni-td>
									<uni-td>{{ item.processName }}</uni-td>
									<uni-td>{{ item.qty }}</uni-td>
									<uni-td>{{ item.createBy_dictText }}			</uni-td>
									<uni-td>		{{item.dataFrom}}		</uni-td>
									<uni-td>		{{item.createTime.substr(0, 10)}}		</uni-td>
								</uni-tr>
							</uni-table>
							<view class="uni-pagination-box"><uni-pagination show-icon :page-size="pageSize" :current="pageCurrent" :total="total" @change="changePage" /></view>
				            </view>
						</drawer>	
			</view>
			
			<view class="example-body">
				<drawer :show="subOrderDrawerShow" @cancel="subOrderCancel" @ensure="subOrderEnsure" >
				<!--            <view>右往左滑动</view>
				            <view>自定义内容</view>		 -->	
							<view style="margin-top: 140rpx;">
							<uni-table ref="table" :loading="loading" border stripe type="selection" emptyText="暂无更多数据" @selection-change="selectionChange">
								<uni-tr>
									<uni-th width="50" align="center">序号</uni-th>		
									<uni-th width="150" align="center">工单号</uni-th>
									<uni-th width="150" align="center">客户</uni-th>
									<uni-th width="120" align="center">产品编码</uni-th>
									<uni-th width="150" align="center">客户料号</uni-th>
									<uni-th width="120" align="center">图号</uni-th>
								    <uni-th width="120" align="center">产品名称</uni-th>
									<uni-th width="150" align="center">版本</uni-th>
									<uni-th width="120" align="center">数量</uni-th>
									<uni-th width="120" align="center">下单日期</uni-th>	
								    <uni-th width="120" align="center">需求日期</uni-th>									
								</uni-tr>
								<uni-tr v-for="(item, index) in itemChilds" :key="index">
									<uni-td>{{ (index + 1) }}</uni-td>
									<uni-td>{{ item.workOrderNumber }}</uni-td>
									<uni-td>{{ item.customerShortName }}</uni-td>
									<uni-td>{{ item.code }}			</uni-td>
									<uni-td>		{{item.custCode}}		</uni-td>
                                    <uni-td>		{{item.drawingNo}}		</uni-td>
									<uni-td>		{{item.name}}		</uni-td>
									<uni-td>		{{item.productVer}}		</uni-td>
									<uni-td>		{{item.qty}}		</uni-td>
									<uni-td>		{{item.orderDate ? item.orderDate : '' }}		</uni-td>
									<uni-td>		{{item.deliveryDate ? item.deliveryDate : '' }}		</uni-td>
								</uni-tr>
							</uni-table>
							<view class="uni-pagination-box"><uni-pagination show-icon :page-size="pageSize" :current="pageCurrent" :total="total" @change="changePage" /></view>
				            </view>
						</drawer>	
			</view>			
			<view class="example-body">
        <drawer :show="drawerShow" @cancel="cancel" @ensure="ensure" >
<!--            <view>右往左滑动</view>
            <view>自定义内容</view>		 -->	
			<view style="margin-top: 140rpx;">
			<uni-table ref="table" :loading="loading" border stripe type="selection" emptyText="暂无更多数据" @selection-change="selectionChange">
				<uni-tr>
					<uni-th width="50" align="center">序号</uni-th>					
					<uni-th width="150" align="center">客户料号</uni-th>
					<uni-th width="120" align="center">日期</uni-th>
					<uni-th width="150" align="center">问题描述</uni-th>
					<uni-th width="120" align="center">不良图片</uni-th>
					
<!-- 					<uni-th align="center">地址</uni-th>
					<uni-th width="204" align="center">设置</uni-th> -->
				</uni-tr>
				<uni-tr v-for="(item, index) in tableData" :key="index">
					<uni-td>{{ (index + 1) }}</uni-td>
					<uni-td>{{ item.custCode }}</uni-td>
					<uni-td>{{ item.samplingDate }}</uni-td>
					<uni-td>
						<view @click="open(item.abnormalDescription)" class="name">{{ item.abnormalDescription ? item.abnormalDescription: ""}}</view>
					</uni-td>
					<uni-td>
						<view>
						    <image
						      class="image"
						      :src="getImage(item)"
						      @click="previewImage($event,item,index)"							  
						    ></image>
						  </view>
					</uni-td>
					<!-- <uni-td align="center">{{ item.address }}</uni-td> -->
<!-- 					<uni-td>
						<view class="uni-group">
							<button class="uni-button" size="mini" type="primary">修改</button>
							<button class="uni-button" size="mini" type="warn">删除</button>
						</view>
					</uni-td> -->
				</uni-tr>
			</uni-table>
			<view class="uni-pagination-box"><uni-pagination show-icon :page-size="pageSize" :current="pageCurrent" :total="total" @change="changePage" /></view>
            </view>
		</drawer>	
		</view>
		<view class="uni-padding-wrap">
<!-- 			<uni-popup ref="popup" :mask-click="false">
				<rich-text class="rich-text-border">Popup</rich-text>
				<button @click="close">关闭</button>
			</uni-popup> -->
			<uni-popup ref="popup" type="center">
			  <view class="contentPop">
					{{popupMessages}}		 
			  </view>
			</uni-popup>
		</view>
		</form>
	</view>
</template>

<script>
	import { USER_INFO} from "@/common/util/constants"
	import socket from '@/common/js-sdk/socket/socket.js'
	import configService from '@/common/service/config.service.js';
	import api from '@/api/api.js'
import { forEach } from "../../common/luch-request/utils";
	export default {
		name:'inputWorkProcessQty',
		data() {
			return {
                popupMessages:'',
				focusState:false,
				index: -1,
				switchC: true,
				empProcess:false,
				queryAbnVisual:false,
				imgList: [],
				range: [],		
				itemChilds : [],
				createQrcodeInCad : false,
				uploadUrl:"/sys/common/upload",
				processIds:'',
				productType : '',
				compQtyName : '完工数量',
				completeFlag : false ,
				isLastProcess: false,
				workprocess: null,
				workProcessItems : null,
				userInfo: null,
				workOrderProcesses:[],
				myFormData:{
					woQty:'',
					custCode:'',
					name:'',
					productVer:'',		
				    employee:'',
					employeeId:'',
					workOrderNumber:'',
					avatar:'',
					realname:'',
					username:'',
					sex:1,
					birthday:'',
					orgCode:'',
					workNo:'',
					phone:'',
					email:'',
					id:'',
				},
				title: 'uni-fab',
				directionStr: '垂直',
				horizontal: 'left',
				vertical: 'bottom',
				direction: 'horizontal',
				pattern: {
					color: '#7A7E83',
					backgroundColor: '#fff',
					selectedColor: '#007AFF',
					buttonColor: '#007AFF',
					iconColor: '#fff',
					icon:'scan'
				},
				is_color_type: false,
				content: [{
						iconPath: '/static/image.png',
						selectedIconPath: '/static/image-active.png',
						text: '相册',
						active: false
					},
					{
						iconPath: '/static/home.png',
						selectedIconPath: '/static/home-active.png',
						text: '首页',
						active: false
					},
					{
						iconPath: '/static/star.png',
						selectedIconPath: '/static/star-active.png',
						text: '收藏',
						active: false
					}
				],
				oldMyformData : {},
				recpList:[],
				url : {
					list: '/wom/womWorkOrder/list-receipt',
				},
				tableData: [],
				// 每页数据量
				pageSize: 10,
				// 当前页
				pageCurrent: 1,
				// 数据总量
				total: 0,
				loading: false,
			    drawerShow:false,
				processDrawerShow:false,
				subOrderDrawerShow:false,
				checkProcessIds : [],
			};
		},
		onLoad: function (option) {
			// this.getEmployee()
		},
		created(){
			this.oldMyformData = this.myFormData
			this.userInfo = uni.getStorageSync(USER_INFO)
			this.myFormData.employee = this.userInfo.realname
			this.myFormData.employeeId = this.userInfo.id
			// this.focusState = true
			this.getEmployee()		
		    this.scan()
			console.log(this.userInfo)
			let _checkProcessIds = uni.getStorageSync('UI_CACHE_SYSTEM_PARAMS')
			if (_checkProcessIds) {
				this.checkProcessIds = _checkProcessIds.split(',')
			}
						
		},
		methods: {
			openSubOrder(){
				this.subOrderDrawerShow = true
			},
			open(text) {
				if (text) {
					this.popupMessages = text
				} else {
					this.popupMessages = ''
				}				
				this.$refs['popup'].open()
				// this.$refs.popup.open('center')
				
			},
			close() {
				this.$refs.popup.close()
			},
			getImage(record) {
				if (record.attachment) {
					return api.getFileAccessHttpUrl(record.attachment.split(',')[0])
				}
			},
			previewImage(e,record,index) {
				debugger
				// 获取图片列表，这里只有一张图片，可以直接放大
				
				let images = record.attachment.split(',');
				let _images = []
				images.forEach((v)=>{
					_images.push( api.getFileAccessHttpUrl(v)	)
				})
				// 调用uni.previewImage方法进行预览
				uni.previewImage({
				  current: _images[0], // 当前显示图片的http链接
				  urls: _images // 需要预览的图片http链接列表
				});
			  },			
			selectionChange(val){
				console.log(val)
			},
            //取消
            cancel() {
                console.log('您点击了取消按钮')
                this.drawerShow = false;
            },
            //确定
            ensure(){
                console.log('您点击了确定按钮')
                this.drawerShow = false;
            },	
				subOrderCancel() {
				    console.log('您点击了取消按钮')
				    this.subOrderDrawerShow = false;
				},
				//确定
				subOrderEnsure(){
				    console.log('您点击了确定按钮')
				    this.subOrderDrawerShow = false;
				},					
				processCancel() {
				    console.log('您点击了取消按钮')
				    this.processDrawerShow = false;
				},
				//确定
				processEnsure(){
				    console.log('您点击了确定按钮')
				    this.processDrawerShow = false;
				},	
			queryAbn(){
				this.drawerShow = true
			},
			// 抽屉状态发生变化触发
			changeDraw(e, type) {
				console.log((type === 'showLeft' ? '左窗口' : '右窗口') + (e ? '打开' : '关闭'));
				this[type] = e
			},
			showDrawer(e) {
				this.$refs[e].open()
			},
			// 关闭窗口
			closeDrawer(e) {
				this.$refs[e].close()
			},
			dispList(item){
				let that = this
				this.$http.get(this.url.list,{params:{workOrderItemId:item.workOrderItemId,processId:item.processId,workOrderProcessId:item.id}}).then(res=>{
					console.log("res::receipt list >",res)
			        if (res.data.result.records) {
						that.recpList = res.data.result.records 
						debugger
						console.log(this.recpList)
						that.$nextTick(()=>{
							// that.showDrawer('showLeft')
							that.processDrawerShow = true
						})
						
					}
				})
			},
			setFocus() {
				let that = this
				this.$nextTick(()=>{
					setTimeout(() => {
								that.focusState = true
						},1000)
				})

			},
			changWo(e) {
				debugger
				console.log(e)
				if (e.detail.value && e.detail.value.length>11) {
					this.myFormData.workOrderNumber = e.detail.value
					this.getWorkOrderData();
				}
			},
			trigger(e) {
				console.log(e)
				this.content[e.index].active = !e.item.active
				uni.showModal({
					title: '提示',
					content: `您${this.content[e.index].active ? '选中了' : '取消了'}${e.item.text}`,
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定')
						} else if (res.cancel) {
							console.log('用户点击取消')
						}
					}
				})
			},
			fabClick() {
				uni.showToast({
					title: '点击了悬浮按钮',
					icon: 'none'
				})
			},
			getEmployee() {
				this.processIds = ''
				console.log("beging find employee.")
				this.$http.get("/bas/basEmployee/list",{params:{code:this.userInfo.username}}).then(res=>{
					console.log("res::employee>",res)
					if (res.data.result.records[0]) {
						this.processIds = res.data.result.records[0].processIds
					}					
				})
			},
			scan(){
				let that = this
				// this.completeFlag = false
				this.focusState = false
				 console.log("进来了")
				// #ifndef H5
				uni.scanCode({
				    success: function (res) {
									  const innerAudioContext = uni.createInnerAudioContext();
												innerAudioContext.autoplay = true;
												innerAudioContext.src = 'https://www.suzi-info.com/13193.wav';  //音频地址
												innerAudioContext.onPlay(() => {
													console.log('开始播放');
												});
												innerAudioContext.onError((res) => {
												  console.log(res.errMsg);
												  console.log(res.errCode);
												});
						let scanDataRes = res.result.split('/')
						console.log(scanDataRes)
						debugger
						if (that.createQrcodeInCad && that.itemChilds.length>0 && scanDataRes && scanDataRes.length == 5) {
							debugger
							if (scanDataRes[4] == "salseorder") {
								that.myFormData.workOrderNumber = scanDataRes[3]
								that.myFormData.qty = ''						
								that.getWorkOrderData("salseorder");
							} else {
								let data = that.findWorkOrderNo(scanDataRes[0])
								console.log(data)
								if (data && data.length>0) {
									that.myFormData.workOrderNumber = data[0].workOrderNumber
									that.myFormData.qty = ''						
									that.getWorkOrderData();
								} else {
									that.notFindWorkOrderNo()
								}
							}
						} else {
							if (scanDataRes && scanDataRes.length == 5) {
								if (scanDataRes[4] == "salseorder") {
									that.myFormData.workOrderNumber = scanDataRes[3]
									that.myFormData.qty = ''						
									that.getWorkOrderData("salseorder");
								} else {
									that.notFindWorkOrderNo()
								}
							} else {
								that.myFormData.workOrderNumber = res.result.split('/')[0]
								that.myFormData.qty = ''						
								that.getWorkOrderData();
							}

						}

				    }
				});
				// #endif
				// #ifdef H5
				this.$tip.alert("暂不支持")
				// #endif
			},
			findWorkOrderNo(code){
				let data = this.itemChilds.filter(item=>item.code == code)
				return data
			},
			notFindWorkOrderNo() {
				this.$tip.toast('没找到子工单数据')
				this.myFormData = {}
				this.processList = []
				this.range = []
				this.myFormData.qty = null
				this.focusState = true			
				this.itemChilds = []
				this.createQrcodeInCad = false
			},
			notFindMainWorkOrderNo() {
				// this.$tip.toast('没找到子工单数据')
				this.myFormData = {}
				this.processList = []
				this.range = []
				this.myFormData.qty = null
				this.focusState = true			
				this.itemChilds = []
				this.createQrcodeInCad = false
			},
			changePage(val){
				console.log(val)
			},
			change(val) {
				console.log("val :",val)
				this.myFormData.balanceQty = this.workProcessItems[val].balanceQty
				this.myFormData.processSeq = this.workProcessItems[val].processSeq
				this.myFormData.qtyPreProcess = this.workProcessItems[val].qtyPreProcess
				this.myFormData.limitedProcessScan = this.workProcessItems[val].limitedProcessScan //限制扫码转序数量
				
				if (this.productType == 2 && val == this.range[this.range.length - 1].value) {
					this.compQtyName = "入库数量"
				} else {
					this.compQtyName = "完工数量"
				}
			},
			getWorkOrderData(scanType){
				let that = this
				this.queryAbnVisual = false
				this.completeFlag = false
				this.itemChilds = []
				this.createQrcodeInCad = false
				if(!this.myFormData.workOrderNumber){
					this.$tip.alert('请输入工单号码！');
					return false
				}
				let param={workOrderNumber:this.myFormData.workOrderNumber,scanType:scanType}
				this.$http.get("/wom/womWorkOrder/getProcessProgressByNo",{params:param}).then(res=>{
					let _data = res.data.result
					let data = _data.filter(p=> p.status != 3)
					console.log("res::workOrderNumber list>",data)
					
					//status = 5 取消
					//status = 4 暂停
					
					if (data && data.length > 0){		
						if (data[0].itemChilds && data[0].itemChilds.length>0 && data[0].createQrcodeInCad ) {
							this.itemChilds = data[0].itemChilds;
							this.createQrcodeInCad = data[0].createQrcodeInCad
						}
						if (data[0].abnProductionAbnormalPageList && data[0].abnProductionAbnormalPageList.length >0) {
							this.tableData = data[0].abnProductionAbnormalPageList
							this.queryAbnVisual = true
							this.tableData.forEach((item,index)=>{
								if (item.attachment) {
									let url = api.getFileAccessHttpUrl((item.attachment).split(',')[0])
									console.log(url)
								}								
							})
						}
						if (data[0].status == 5) {
							this.$tip.toast('工单已取消，无法转序！')
							return
						}
						if (data[0].status == 4) {
							this.$tip.toast('工单暂停中请联系主管！')
							return
						}
						if (data[0].status == 3) {
							// this.completeFlag = true
							this.$tip.toast('工单已完成，不可转序！')
							// return
						}
						this.workOrderProcesses = data
						this.processList = []
						if (scanType && scanType == "salseorder") {
							this.myFormData.workOrderNumber = data[0].workOrderNumber
						}
						this.myFormData.woQty = data[0].qtyWorkOrder
						this.myFormData.qtyPreProcess = data[0].qtyPreProcess
						this.myFormData.custCode = data[0].custCode
						this.myFormData.name = data[0].name
						this.myFormData.productVer = data[0].productVer
						this.myFormData.employee = this.userInfo.username
						this.myFormData.attribute = data[0].attribute
						this.myFormData.processSeq = data[0].processSeq
						this.myFormData.limitedProcessScan = data[0].limitedProcessScan
						this.productType = data[0].productType
						this.workprocess = {}
						this.workProcessItems = {}
						data.forEach((item)=>{
							if (item.processSeq == 1) { //第一道工序
								item.balanceQty = 0
							} else {
							    item.balanceQty = (item.qtyPreProcess == null ? 0 : item.qtyPreProcess) - (item.qty == null ? 0:item.qty)
							}						
							let obj = {value:item.id,text:item.processId_dictText}
							// this.workprocess[item.processId] = item //有重复记录
							this.workProcessItems[item.id] = item
							if (item.processAttribute && (item.processAttribute == 1 || item.processAttribute == 3)) {
								this.processList.push(obj)			
							}			
						})
						console.log("list:",this.processList)
						this.range = this.processList
						if (this.processIds) {
							this.processList = []
							let psIds = this.processIds.split(',')
							console.log(psIds,"ididididi")							
							let processListone = []
							data.forEach((item)=>{
								// if (item.processId == this.processIds) {
								// 	let obj = {value:item.id,text:item.processId_dictText + item.processSeq}
								// 	let _objone = {value:item.id,text:item.processId_dictText}
								// 	if (item.processAttribute && item.processAttribute == 1) {
								// 		this.processList.push(obj)	
								// 	    processListone.push(_objone)
								// 	}	
								// }
								let _v = psIds.find(id=>id == item.processId)
								if (_v) {
									let obj = {value:item.id,text:item.processId_dictText + item.processSeq}
									let _objone = {value:item.id,text:item.processId_dictText}
									if (item.processAttribute && (item.processAttribute == 1 || item.processAttribute == 3)) {
										this.processList.push(obj)	
										processListone.push(_objone)
									}	
								}
							})
						    let _id = this.processList[0].value
							this.myFormData.id = this.processList[0].value
							this.myFormData.qtyPreProcess = this.workProcessItems[_id].qtyPreProcess
							this.myFormData.balanceQty = this.workProcessItems[_id].balanceQty
							this.myFormData.processSeq = this.workProcessItems[_id].processSeq
							this.myFormData.limitedProcessScan = this.workProcessItems[_id].limitedProcessScan
							if (this.processList.length > 1) {
							  this.range = this.processList
							} else {
							  this.range = processListone
							}
							// this.empProcess = true
						}
						// this.myFormData.balanceQty = data[0].balanceQty  解决前道工序为零
						this.myFormData.qty = null
						that.setFocus()
					} else {
						this.$tip.toast('未找到工单数据！')
						this.notFindMainWorkOrderNo()
					}

					
				})
			},			
			onSubmit(status) {
			  let that = this
			  let myForm = this.myFormData
			 //  let checkPhone = new RegExp(/^[1]([3-9])[0-9]{9}$/);
			 //  let checkEmail = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/;
			 //  console.log("myForm",myForm)
			 if(!myForm.id){
			 				this.$tip.alert('请选择工序');
			 				return false
			 }
			  if(!myForm.qty || myForm.qty==0){
				this.$tip.alert('请输入数量');
				return false
			  }
			  if (myForm.balanceQty && myForm.balanceQty < 0) {
				  if (this.myFormData.limitedProcessScan) { //系统设定限制就检查数量
					  this.$tip.toast('数量超出了可转序数量！')
					  return false
				  }
			  }
			  if (myForm.balanceQty && myForm.balanceQty < myForm.qty && myForm.balanceQty > 0 && this.myFormData.processSeq !=1) {
				  if (this.myFormData.limitedProcessScan) { //系统设定限制就检查数量
					  this.$tip.toast('数量超出了可转序数量！')
					  return false
				  }
			  }
			  if ((!this.myFormData.qtyPreProcess || this.myFormData.qtyPreProcess == 0) && this.myFormData.processSeq !=1) {
				if (this.myFormData.limitedProcessScan) { //系统设定限制就检查数量
					this.$tip.toast("没有可以转序的数量！") 
					return false
				}
			  }
				console.log('myform',this.myFormData)
				this.myFormData.completeStatus = status
				this.$tip.loading();
				this.$http.post('/wom/womWorkOrder/delivery',this.myFormData).then(res=>{
					console.log(res)
					this.$tip.loaded();
					if (res.data.success){
						this.$tip.toast('提交成功')
						this.myFormData = {}
						this.processList = []
						this.range = []
						this.myFormData.qty = null
						this.focusState = true			
						this.itemChilds = []
						this.createQrcodeInCad = false
					    // socket.send({value:"保存成功！",userUid:"F0027",method:"2",category:'2'},this.callback(res))	
					} else {
						this.myFormData = {}
						this.processList = []
						this.range = []
						this.myFormData.qty = null
						this.focusState = true			
						this.itemChilds = []
						this.createQrcodeInCad = false
						this.$tip.toast(res.data.message)
					}					
				}).catch(()=>{
					this.$tip.loaded();
					this.$tip.error('提交失败')
				});
			},
			callback(res) {
				console.log("发送状态：",res)
			},
			DateChange(e) {
				this.myFormData.birthday = e.detail.value
			},
			SwitchC(e) {
				this.switchC = e.detail.value
			},
			ChooseImage() {
				var that=this;
				uni.chooseImage({
					count: 4, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album'], //从相册选择
					success: (res) => {
						that.$http.upload(that.$config.apiUrl+that.uploadUrl, {
								filePath: res.tempFilePaths[0],
								name: 'file'
							})
							.then(res => {
								that.myFormData.avatar=res.data.message;
							})
							.catch(err => {
								that.$tip.error(err.data.message)
							});
						this.imgList = res.tempFilePaths
					}
				});
			},
			ViewImage(e,record) {
				uni.previewImage({
					urls: this.imgList,
					current: e.currentTarget.dataset.url
				});
			},
			DelImg(e) {
				uni.showModal({
					title: '召唤师',
					content: '确定要删除这段回忆吗？',
					cancelText: '再看看',
					confirmText: '再见',
					success: res => {
						if (res.confirm) {
							this.imgList.splice(e.currentTarget.dataset.index, 1)
						}
					}
					
				})
			}
		}
	}
</script>

<style>
	.cu-form-group .title {
		min-width: calc(4em + 15px);
		font-weight: 600;
	}
	.button-sp-area {
/*        background: white;
		margin: 11px 88px 10px; */
	}
	.spanStyle {
		    background: red;
		    padding: 3px 5px;
		    word-break: break-word;
		    margin: 3px;
		    border-radius: 5px;
		    color: white;
		    font-size: 12px;
/* 		    cursor: pointer; */
	}
	.spanStyle1 {
			    background: #11c410;
			    padding: 3px 5px;
			    word-break: break-word;
			    margin: 3px;
			    border-radius: 5px;
			    color: white;
			    font-size: 12px;
	/* 		    cursor: pointer; */
		}
	.spanStyle2 {
			    background: #c0c4cc;
			    padding: 3px 5px;
			    word-break: break-word;
			    margin: 3px;
			    border-radius: 5px;
			    color: white;
			    font-size: 12px;
	/* 		    cursor: pointer; */
		}
		.gProgress {
		     color: black;
		     width: 240px;
		     height: 40px;
		     padding: 3px 5px;
		     border-radius: 6px;
		     background: linear-gradient( 90deg, #c30e0e, rgb(194, 199, 199) 70%, transparent 0);
		     border: 1px solid #c0c4cc;
		 }
		.container-btn {
		  display: flex;
		  justify-content: center; /* 水平居中 */
		  align-items: center; /* 垂直居中 */
		  height: 100%; /* 父容器需要有确定的高度 */
		}
	.example-body {
		padding: 10px;
	}

	.scroll-view {
		/* #ifndef APP-NVUE */
		width: 100%;
		height: 100%;
		/* #endif */
		flex: 1
	}

	// 处理抽屉内容滚动
	.scroll-view-box {
		flex: 1;
		position: absolute;
		top: 0;
		right: 0;
		bottom: 0;
		left: 0;
	}

	.info {
		padding: 15px;
		color: #666;
	}

	.info-text {
		font-size: 14px;
		color: #666;
	}

	.info-content {
		padding: 5px 15px;
	}

	.close {
		padding: 10px;
	}
 .image {
    width: 30px; /* 设置图片宽度 */
    height: 20px; /* 设置图片高度 */
  }	
  
  .rich-text-border {
    border: 1px solid #000; /* 黑色边框 */
    border-radius: 5px; /* 可选：圆角边框 */
  }
    .contentPop {
      padding: 20px;
	   border-radius: 5px;
      background-color: #fff;
    }
</style>
